home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Add-Ons / After Dark / Joe Judge / Blot ƒ / module.c < prev   
Encoding:
C/C++ Source or Header  |  1994-08-06  |  4.3 KB  |  168 lines  |  [TEXT/KAHL]

  1.  
  2.  
  3. #include "GraphicsModule_Types.h"
  4. #include "Sounds.h"
  5.  
  6. #include "blot.h"
  7. #include "utils.h"
  8.  
  9. // these are the functs that need defined ...
  10. OSErr DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params);
  11. OSErr DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  12. OSErr DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  13. OSErr DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  14. OSErr DoSetUp(RgnHandle blankRgn, short message, GMParamBlockPtr params);
  15. // these must be defined also
  16. OSErr DoSelected(RgnHandle blankRgn, short message, GMParamBlockPtr params);
  17. OSErr DoAboutBox(RgnHandle blankRgn, short message, GMParamBlockPtr params);
  18.  
  19. extern short gTimeout;
  20. extern Boolean gXsym, gYsym;
  21. extern short gMaxpoints, gOffset;
  22.  
  23. #define ABOUT_PICT 1024
  24.  
  25. //////////////////////////////////////////////////////////////////////////////////////
  26. // this is the first funct called by AD ... we need to allocate and initialize here
  27. OSErr
  28. DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params) {
  29. int i;
  30.  
  31.     gMaxpoints = (10 + params->controlValues[2] ) * 10;
  32.     if (gMaxpoints > MAXPOINTS) gMaxpoints = MAXPOINTS;
  33.         
  34.     gOffset = 1 + (params->controlValues[0] / 10);    
  35.     
  36.     
  37.     for (i=0; i<params->monitors->monitorCount; i++) 
  38.         initblot( i, &(params->monitors->monitorList[i].bounds),
  39.             params->monitors->monitorList[i].curDepth );
  40.             
  41.     return noErr;
  42. }
  43.  
  44. //////////////////////////////////////////////////////////////////////////////////////
  45. // the screen saver has been awakened! time to ditch the storage and wave goodbye
  46. OSErr 
  47. DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params) {
  48.  
  49.  
  50.     return noErr;
  51. }
  52.  
  53.  
  54.  
  55. //////////////////////////////////////////////////////////////////////////////////////
  56. // make the screen go black
  57. OSErr
  58. DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params) {
  59.  
  60.     // darken the screen ...
  61.     // FillRgn(blankRgn, params->qdGlobalsCopy->qdBlack);
  62.     return noErr;
  63.  
  64. }
  65.  
  66. //////////////////////////////////////////////////////////////////////////////////////
  67. // this is the workhorse routine. It does the continual screen work to make
  68. // this screen saver what it is.
  69. OSErr 
  70. DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params) 
  71. {
  72. static currentScreen = 0;
  73.  
  74.     
  75.     if (params->controlValues[1] == 1)        // often
  76.         gTimeout = 5;
  77.     else if (params->controlValues[1] == 2)    // normal
  78.         gTimeout = 30;
  79.     else if (params->controlValues[1] == 3)    // never
  80.         gTimeout = 0;
  81.     
  82.     gXsym = (params->controlValues[3] == 1 || params->controlValues[3] == 3);
  83.     gYsym = (params->controlValues[3] == 2 || params->controlValues[3] == 3);
  84.     
  85.     gOffset = 1 + (params->controlValues[0] / 10);    
  86.     
  87.     gMaxpoints = (10 + params->controlValues[2] ) * 10;
  88.     if (gMaxpoints > MAXPOINTS) gMaxpoints = MAXPOINTS;
  89.  
  90.  
  91.     if (currentScreen >= params->monitors->monitorCount)
  92.         currentScreen = 0;
  93.         
  94.     drawblot( currentScreen, 
  95.         &(params->monitors->monitorList[currentScreen].bounds),
  96.         params->monitors->monitorList[currentScreen].curDepth);
  97.     
  98.     currentScreen++;
  99.     
  100.     return noErr;
  101. }
  102.  
  103. //////////////////////////////////////////////////////////////////////////////////////
  104. // this is called when they click on something in the control panel
  105. OSErr 
  106. DoSetUp(RgnHandle blankRgn, short message, GMParamBlockPtr params) {
  107.     // button got pushed?? 
  108.     return noErr;
  109. }
  110.  
  111.  
  112.  
  113. OSErr DoSelected(RgnHandle blankRgn, short message, GMParamBlockPtr params) {
  114.     return noErr;
  115. }
  116.  
  117.  
  118.  
  119. OSErr DoAboutBox(RgnHandle blankRgn, short message, GMParamBlockPtr params) {
  120.     GrafPtr savePort;
  121.     short pixelSize;
  122.     PicHandle    pictH;
  123.     
  124.  
  125.     gTimeout = 20;
  126.     gXsym = TRUE;            // randomize these?
  127.     gYsym = FALSE;
  128.     gMaxpoints = 1000;
  129.     gOffset = 4;
  130.     
  131.     GetPort( &savePort);
  132.     
  133.     if (HasColorQD()) 
  134.         pixelSize = ( *((CGrafPtr)savePort)->portPixMap)->pixelSize;
  135.     else 
  136.         pixelSize = 1;
  137.  
  138. ////////////////// do the animation /////////////////////////////
  139.     initblot( 0, &(savePort->portRect), pixelSize);
  140.     
  141.     while (!Button()) 
  142.         drawblot( 0, &(savePort->portRect), pixelSize);
  143.  
  144.     BackColor(blackColor);
  145.     EraseRect( &(savePort->portRect) );
  146.  
  147. ///////////////// do the picture ///////////////////////////////
  148.     pictH = GetPicture(ABOUT_PICT);
  149.     if (pictH == NULL) 
  150.         SysBeep(0);
  151.     else {
  152.     long waste;
  153.     
  154.         DrawPicture( pictH, &(*pictH)->picFrame);
  155.         ReleaseResource( (Handle)pictH);
  156.         Delay( 30, &waste);
  157.     }
  158.     while (!Button())
  159.         ;
  160.     while (StillDown())
  161.         ;
  162.     FlushEvents(everyEvent, 0);        // this is for Darkside 
  163.  
  164.     return noErr;
  165. }
  166.  
  167.  
  168.